<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css"></style>

</head>
<body>
    <h1>JS 的数值类型</h1>
    <hr>

    <script>
        var num = 123; // 10
        var num = 0b110; // 2
        var num = 010; // 8
        var num = 0xff; // 16
        var num = 23e2; // 科学计数法
        var num = 23e-2; // 科学计数法
        console.log('值: ', num);
        console.log('类型: ', typeof(num));

        // Not a Number
        var num = NaN;
        if (NaN) {
            console.log('yes');
        }else {
            console.log('no');
        }

        if (NaN == NaN) {
            console.log('yes');
        }else {
            console.log('no');
        }

        console.log(NaN + 100);
        // 将其他类型转换,转换不成功 则成NaN.
        // Number()  parseInt()  parseFloat()

        var a = 'hi';
        var a = '123';
        var a = '123111.455';
        var a = '123abcdef';
        var a = '';
        // var a = true;
        // var a = false;
        // var a = null;
        // var a = undefined;

        // var n = Number(a);
        var n = parseInt(a);
        // var n = parseFloat(a);

        console.log('值: ', n);
        console.log('类型: ', typeof(n));

        // isNaN();
        console.log(isNaN('12'));
        console.log(isNaN('12as'));

    </script>

</body>
</html>




